/*
 * This file is part of Cadmium.
 * Copyright (C) 2007-2010 Xavier Clerc.
 *
 * Cadmium is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cadmium is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package fr.x9c.cadmium.primitives.cadmiumjdbc;

import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;

import fr.x9c.cadmium.kernel.Block;
import fr.x9c.cadmium.kernel.Channel;
import fr.x9c.cadmium.kernel.CodeRunner;
import fr.x9c.cadmium.kernel.Custom;
import fr.x9c.cadmium.kernel.Fail;
import fr.x9c.cadmium.kernel.Primitive;
import fr.x9c.cadmium.kernel.PrimitiveProvider;
import fr.x9c.cadmium.kernel.Value;
import fr.x9c.cadmium.primitives.cadmium.Cadmium;

/**
 * This class provides the primitives related to the <tt>java.sql.CallableStatement</tt> class.
 *
 * @author <a href="mailto:cadmium@x9c.fr">Xavier Clerc</a>
 * @version 1.1
 * @since 1.1
 */
@PrimitiveProvider
public final class CallableStatements {

    /**
     * No instance of this class.
     */
    private CallableStatements() {
    } // end empty constructor

    /**
     * Returns the parameter at the given index as an array value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as an array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_array_idx(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Array value = cs.getArray(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_array_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as an array value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as an array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_array_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Array value = cs.getArray(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_array_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a big decimal value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a big decimal value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_big_decimal_idx(final CodeRunner ctxt,
                                                                          final Value callableStatement,
                                                                          final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final BigDecimal value = cs.getBigDecimal(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_big_decimal_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a big decimal value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a big decimal value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_big_decimal_name(final CodeRunner ctxt,
                                                                           final Value callableStatement,
                                                                           final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final BigDecimal value = cs.getBigDecimal(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_big_decimal_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a blob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a blob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_blob_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Blob value = cs.getBlob(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_blob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a blob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a blob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_blob_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Blob value = cs.getBlob(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_blob_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a boolean value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a boolean value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_boolean_idx(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final boolean value = cs.getBoolean(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, value ? Value.TRUE : Value.FALSE);
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_boolean_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a boolean value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a boolean value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_boolean_name(final CodeRunner ctxt,
                                                                       final Value callableStatement,
                                                                       final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final boolean value = cs.getBoolean(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, value ? Value.TRUE : Value.FALSE);
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_boolean_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a byte value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a byte value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_byte_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final byte value = cs.getByte(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_byte_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a byte value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a byte value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_byte_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final byte value = cs.getByte(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_byte_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a byte array value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a byte array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_bytes_idx(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final byte[] value = cs.getBytes(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_bytes_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a byte array value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a byte array value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_bytes_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final byte[] value = cs.getBytes(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_bytes_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a clob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a clob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_clob_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Clob value = cs.getClob(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_clob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a clob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a clob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_clob_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Clob value = cs.getClob(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_clob_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a date value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a date value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_date_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Date value = cs.getDate(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_date_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a date value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a date value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_date_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Date value = cs.getDate(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_date_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a double value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a double value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_double_idx(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final double value = cs.getDouble(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_double_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a double value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a double value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_double_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final double value = cs.getDouble(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_double_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a float value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a float value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_float_idx(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final float value = cs.getFloat(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_float_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a float value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a float value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_float_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final float value = cs.getFloat(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createDouble(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_float_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as an integer value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as an integer value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_int_idx(final CodeRunner ctxt,
                                                                  final Value callableStatement,
                                                                  final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final int value = cs.getInt(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_32_SIZE,
                                                   Custom.INT_32_OPS);
                b.setInt32(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_int_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as an integer value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as an integer value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_int_name(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final int value = cs.getInt(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_32_SIZE,
                                                   Custom.INT_32_OPS);
                b.setInt32(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_int_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a long value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a long value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_long_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final long value = cs.getLong(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_64_SIZE,
                                                   Custom.INT_64_OPS);
                b.setInt64(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_long_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a long value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a long value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_long_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final long value = cs.getLong(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block b = Block.createCustom(Custom.INT_64_SIZE,
                                                   Custom.INT_64_OPS);
                b.setInt64(value);
                final Block res  = Block.createBlock(0, Value.createFromBlock(b));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_long_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a nclob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a nclob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_nclob_idx(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final NClob value = cs.getNClob(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_nclob_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a nclob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a nclob value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_nclob_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final NClob value = cs.getNClob(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_nclob_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a nstring value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a nstring value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_nstring_idx(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final String value = cs.getNString(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_nstring_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a nstring value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a nstring value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_nstring_name(final CodeRunner ctxt,
                                                                       final Value callableStatement,
                                                                       final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final String value = cs.getNString(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_nstring_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as an object value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as an object value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_object_idx(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Object value = cs.getObject(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_object_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as an object value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as an object value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_object_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Object value = cs.getObject(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_object_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a reference value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a reference value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_ref_idx(final CodeRunner ctxt,
                                                                  final Value callableStatement,
                                                                  final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Ref value = cs.getRef(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_ref_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a reference value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a reference value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_ref_name(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Ref value = cs.getRef(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_ref_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a row id value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a row id value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_row_id_idx(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final RowId value = cs.getRowId(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_row_id_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a row id value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a row id value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_row_id_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final RowId value = cs.getRowId(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_row_id_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a short value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a short value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_short_idx(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final short value = cs.getShort(idx.asLong());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_short_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a short value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a short value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_short_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final short value = cs.getShort(name.asBlock().asString());
            if (cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromLong(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_short_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a SQL XML value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a SQL XML value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_sqlxml_idx(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final SQLXML value = cs.getSQLXML(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_sqlxml_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a SQL XML value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a SQL XML value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_sqlxml_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final SQLXML value = cs.getSQLXML(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_sqlxml_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a string value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a string value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_string_idx(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final String value = cs.getString(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_string_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a string value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a string value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_string_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final String value = cs.getString(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value)));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_string_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a time value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a time value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_time_idx(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Time value = cs.getTime(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_time_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a time value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a time value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_time_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Time value = cs.getTime(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_time_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a timestamp value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a timestamp value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_timestamp_idx(final CodeRunner ctxt,
                                                                        final Value callableStatement,
                                                                        final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Timestamp value = cs.getTimestamp(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_timestamp_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a timestamp value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a timestamp value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_timestamp_name(final CodeRunner ctxt,
                                                                         final Value callableStatement,
                                                                         final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final Timestamp value = cs.getTimestamp(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Cadmium.createObject(value));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_timestamp_name(CodeRunner, Value, Value)'

    /**
     * Returns the parameter at the given index as a URL value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @return the parameter at the given index as a URL value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_url_idx(final CodeRunner ctxt,
                                                                  final Value callableStatement,
                                                                  final Value idx)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final URL value = cs.getURL(idx.asLong());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value.toString())));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_url_idx(CodeRunner, Value, Value)'

    /**
     * Returns the parameter with the given name as a URL value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @return the parameter with the given name as a URL value
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_get_url_name(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value name)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            final URL value = cs.getURL(name.asBlock().asString());
            if ((value == null) || cs.wasNull()) {
                return Value.ZERO;
            } else {
                final Block res  = Block.createBlock(0, Value.createFromBlock(Block.createString(value.toString())));
                return Value.createFromBlock(res);
            } // end if/else
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_get_url_name(CodeRunner, Value, Value)'

    /**
     * Registers the <i>out</i> parameter at the given index to the passed JDBC type.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @param type parameter type
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_register_out_parameter_idx(final CodeRunner ctxt,
                                                                                 final Value callableStatement,
                                                                                 final Value idx,
                                                                                 final Value type)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            cs.registerOutParameter(idx.asLong(), Misc.decodeJDBCType(type));
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_register_out_parameter_idx(CodeRunner, Value, Value, Value)'

    /**
     * Registers the <i>out</i> parameter at the given index to the passed JDBC type and scale.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param idx parameter index
     * @param type parameter type
     * @param scale parameter scale
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_register_out_parameter_scale_idx(final CodeRunner ctxt,
                                                                                       final Value callableStatement,
                                                                                       final Value idx,
                                                                                       final Value type,
                                                                                       final Value scale)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            cs.registerOutParameter(idx.asLong(), Misc.decodeJDBCType(type), scale.asLong());
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_register_out_parameter_scale_idx(CodeRunner, Value, Value, Value, Value)'

    /**
     * Registers the <i>out</i> parameter with the given name to the passed JDBC type and scale.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param type parameter type
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_register_out_parameter_name(final CodeRunner ctxt,
                                                                                  final Value callableStatement,
                                                                                  final Value name,
                                                                                  final Value type)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            cs.registerOutParameter(name.asBlock().asString(), Misc.decodeJDBCType(type));
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_register_out_parameter_name(CodeRunner, Value, Value, Value)'

    /**
     * Registers the <i>out</i> parameter with the given name to the passed JDBC type and scale.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param type parameter type
     * @param scale parameter scale
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_register_out_parameter_scale_name(final CodeRunner ctxt,
                                                                                        final Value callableStatement,
                                                                                        final Value name,
                                                                                        final Value type,
                                                                                        final Value scale)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            cs.registerOutParameter(name.asBlock().asString(), Misc.decodeJDBCType(type), scale.asLong());
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_register_out_parameter_scale_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an ASCII stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_ascii_stream_name(final CodeRunner ctxt,
                                                                            final Value callableStatement,
                                                                            final Value name,
                                                                            final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setAsciiStream(name.asBlock().asString(), ch.asInputStream());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARCHAR);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_ascii_stream_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an ASCII stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_ascii_stream_length_name(final CodeRunner ctxt,
                                                                                   final Value callableStatement,
                                                                                   final Value name,
                                                                                   final Value x,
                                                                                   final Value length)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setAsciiStream(name.asBlock().asString(), ch.asInputStream(),
                                  length.asBlock().asInt32());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARCHAR);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_ascii_stream_length_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an ASCII stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_ascii_stream_length64_name(final CodeRunner ctxt,
                                                                                     final Value callableStatement,
                                                                                     final Value name,
                                                                                     final Value x,
                                                                                     final Value length)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setAsciiStream(name.asBlock().asString(), ch.asInputStream(),
                                  length.asBlock().asInt64());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARCHAR);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_ascii_stream_length64_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a big decimal value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_big_decimal_name(final CodeRunner ctxt,
                                                                           final Value callableStatement,
                                                                           final Value name,
                                                                           final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setBigDecimal(name.asBlock().asString(),
                                 (BigDecimal) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.NUMERIC);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_big_decimal_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a binary stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_binary_stream_name(final CodeRunner ctxt,
                                                                             final Value callableStatement,
                                                                             final Value name,
                                                                             final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setBinaryStream(name.asBlock().asString(), ch.asInputStream());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARBINARY);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_binary_stream_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a binary stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_binary_stream_length_name(final CodeRunner ctxt,
                                                                                    final Value callableStatement,
                                                                                    final Value name,
                                                                                    final Value x,
                                                                                    final Value length)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setBinaryStream(name.asBlock().asString(), ch.asInputStream(),
                                   length.asBlock().asInt32());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARBINARY);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_binary_stream_length_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a binary stream.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param length stream length
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_binary_stream_length64_name(final CodeRunner ctxt,
                                                                                      final Value callableStatement,
                                                                                      final Value name,
                                                                                      final Value x,
                                                                                      final Value length)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                final Channel ch = (Channel) x.asBlock().get(0).asBlock().asCustom();
                cs.setBinaryStream(name.asBlock().asString(), ch.asInputStream(),
                                   length.asBlock().asInt64());
            } else {
                cs.setNull(name.asBlock().asString(), Types.LONGVARBINARY);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_binary_stream_length64_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a blob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_blob_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setBlob(name.asBlock().asString(),
                           (Blob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.BLOB);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_blob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a boolean value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_boolean_name(final CodeRunner ctxt,
                                                                       final Value callableStatement,
                                                                       final Value name,
                                                                       final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setBoolean(name.asBlock().asString(),
                              x.asBlock().get(0) == Value.TRUE);
            } else {
                cs.setNull(name.asBlock().asString(), Types.BOOLEAN);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_boolean_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a byte value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_byte_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setByte(name.asBlock().asString(), (byte) x.asBlock().get(0).asLong());
            } else {
                cs.setNull(name.asBlock().asString(), Types.TINYINT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_byte_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a byte array value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_bytes_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name,
                                                                     final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setBytes(name.asBlock().asString(), x.asBlock().get(0).asBlock().getBytes());
            } else {
                try {
                    cs.setNull(name.asBlock().asString(), Types.VARBINARY);
                } catch (final SQLException se) {
                    cs.setNull(name.asBlock().asString(), Types.LONGVARBINARY);
                } // end try/catch
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_bytes_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a clob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_clob_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setClob(name.asBlock().asString(),
                           (Clob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.CLOB);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_clob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a date value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_date_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setDate(name.asBlock().asString(),
                           (Date) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.DATE);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_date_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a double value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_double_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setDouble(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asDouble());
            } else {
                cs.setNull(name.asBlock().asString(), Types.DOUBLE);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_double_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a float value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_float_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name,
                                                                     final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setFloat(name.asBlock().asString(),
                            (float) x.asBlock().get(0).asBlock().asDouble());
            } else {
                cs.setNull(name.asBlock().asString(), Types.REAL);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_float_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an int value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_int_name(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value name,
                                                                   final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setInt(name.asBlock().asString(),
                          x.asBlock().get(0).asBlock().asInt32());
            } else {
                cs.setNull(name.asBlock().asString(), Types.INTEGER);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_int_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a long value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_long_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setLong(name.asBlock().asString(),
                           x.asBlock().get(0).asBlock().asInt64());
            } else {
                cs.setNull(name.asBlock().asString(), Types.BIGINT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_long_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a nclob value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_nclob_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name,
                                                                     final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setNClob(name.asBlock().asString(),
                            (NClob) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.NCLOB);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_nclob_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a nstring value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_nstring_name(final CodeRunner ctxt,
                                                                       final Value callableStatement,
                                                                       final Value name,
                                                                       final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setNString(name.asBlock().asString(),
                              x.asBlock().get(0).asBlock().asString());
            } else {
                try {
                    cs.setNull(name.asBlock().asString(), Types.NCHAR);
                } catch (final SQLException se1) {
                    try {
                        cs.setNull(name.asBlock().asString(), Types.NVARCHAR);
                    } catch (final SQLException se2) {
                        cs.setNull(name.asBlock().asString(), Types.LONGNVARCHAR);
                    } // end try/catch
                } // end try/catch
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_nstring_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an object value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_object_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setObject(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.JAVA_OBJECT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_object_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an object value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param type JDBC type the passed object value should be mapped to
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_object_type_name(final CodeRunner ctxt,
                                                                           final Value callableStatement,
                                                                           final Value name,
                                                                           final Value x,
                                                                           final Value type)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setObject(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asCustom(),
                             Misc.decodeJDBCType(type));
            } else {
                cs.setNull(name.asBlock().asString(), Types.JAVA_OBJECT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_object_type_name(CodeRunner, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to an object value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @param type JDBC type the passed object value should be mapped to
     * @param scale scale of length the passed object value should be converted to
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_object_type_scale_name(final CodeRunner ctxt,
                                                                                 final Value callableStatement,
                                                                                 final Value name,
                                                                                 final Value x,
                                                                                 final Value type,
                                                                                 final Value scale)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setObject(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asCustom(),
                             Misc.decodeJDBCType(type),
                             scale.asLong());
            } else {
                cs.setNull(name.asBlock().asString(), Types.JAVA_OBJECT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_object_type_scale_name(CodeRunner, Value, Value, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a row id value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_row_id_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setRowId(name.asBlock().asString(),
                            (RowId) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.ROWID);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_row_id_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a short value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_short_name(final CodeRunner ctxt,
                                                                     final Value callableStatement,
                                                                     final Value name,
                                                                     final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setShort(name.asBlock().asString(),
                            (short) x.asBlock().get(0).asLong());
            } else {
                cs.setNull(name.asBlock().asString(), Types.SMALLINT);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_short_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a SQL XML value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_sqlxml_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setSQLXML(name.asBlock().asString(),
                             (SQLXML) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.SQLXML);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_sqlxml_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a string value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_string_name(final CodeRunner ctxt,
                                                                      final Value callableStatement,
                                                                      final Value name,
                                                                      final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setString(name.asBlock().asString(),
                             x.asBlock().get(0).asBlock().asString());
            } else {
                try {
                    cs.setNull(name.asBlock().asString(), Types.VARCHAR);
                } catch (final SQLException se) {
                    cs.setNull(name.asBlock().asString(), Types.LONGVARCHAR);
                } // end try/catch
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_string_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a time value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_time_name(final CodeRunner ctxt,
                                                                    final Value callableStatement,
                                                                    final Value name,
                                                                    final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setTime(name.asBlock().asString(),
                           (Time) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.TIME);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_time_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a timestamp value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_timestamp_name(final CodeRunner ctxt,
                                                                         final Value callableStatement,
                                                                         final Value name,
                                                                         final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setTimestamp(name.asBlock().asString(),
                                (Timestamp) x.asBlock().get(0).asBlock().asCustom());
            } else {
                cs.setNull(name.asBlock().asString(), Types.TIMESTAMP);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_timestamp_name(CodeRunner, Value, Value, Value)'

    /**
     * Sets the parameter with the given name to a URL value.
     * @param ctxt context
     * @param callableStatement callable statement
     * @param name parameter name
     * @param x parameter value
     * @return <i>unit</i>
     * @throws Fail.Exception if any error occurs
     */
    @Primitive
    public static Value cadmiumjdbc_callablestatement_set_url_name(final CodeRunner ctxt,
                                                                   final Value callableStatement,
                                                                   final Value name,
                                                                   final Value x)
        throws Fail.Exception {
        try {
            final CallableStatement cs =
                (CallableStatement) callableStatement.asBlock().asCustom();
            if (x.isBlock()) {
                cs.setURL(name.asBlock().asString(),
                          new URL(x.asBlock().get(0).asBlock().asString()));
            } else {
                cs.setNull(name.asBlock().asString(), Types.DATALINK);
            } // end if/else
            return Value.UNIT;
        } catch (final Exception e) {
            Cadmium.fail(ctxt, e);
            return Value.UNIT; // never reached
        } // end try/catch
    } // end method 'cadmiumjdbc_callablestatement_set_url_name(CodeRunner, Value, Value, Value)'

} // end class 'CallableStatements'
